import request from '@/utils/request';

export async function promoterAdd(data) {
  const res = await request.post('promoter/add', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function promoterEdit(data) {
  const res = await request.post('promoter/edit', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function editState(data) {
  const res = await request.post('promoter/editState', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 推广员列表
export async function promoterGetList(data) {
  const res = await request.post('promoter/getList', data);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 推广员详情
export async function promoterGetInfo(data) {
  const res = await request.post('promoter/getInfo', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 合伙人详情
export async function associateGetInfo(data) {
  const res = await request.post('associate/getInfo', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 数据统计
export async function associateStatistic(data) {
  const res = await request.post('associate/statistic', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 合伙人支付记录

export async function getAssociatePaylist(data) {
  const res = await request.post('getAssociatePaylist', data);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 推广员用户列表
export async function getPromoterUserList(data) {
  const res = await request.post('getPromoterUserList', data);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 合伙人用户列表

export async function getAssociateUserList(data) {
  const res = await request.post('getAssociateUserList', data);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
